package com.lei.yohuo001java.fragmentyouhuo;

import androidx.fragment.app.Fragment;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.blankj.utilcode.util.SPUtils;
import com.lei.mvp_retrofitlibrary.mvp.view.BaseFragment;
import com.lei.yohuo001java.LoginActivity;
import com.lei.yohuo001java.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class FourFragment extends BaseFragment {
    public static Button bt1Four;
    public static TextView tv1Four;
    public static Button bt2LogFour;

    @Override
    public int bindlayout() {
        return R.layout.fragment_four;
    }

    @Override
    public void initView() {
        bt1Four = (Button) findViewById(R.id.bt1_four);
        tv1Four = (TextView) findViewById(R.id.tv1_four);
        bt2LogFour = (Button) findViewById(R.id.bt2_log_four);

    }

    @Override
    public void initData() {

        bt1Four.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (SPUtils.getInstance().getBoolean("log")){
                    tv1Four.setText("用户已登出");
                    bt2LogFour.setVisibility(View.VISIBLE);
                    bt1Four.setVisibility(View.GONE);
                    SPUtils.getInstance().remove("log");
                }else {
                    Toast.makeText(getContext(), "用户还未登录,请先登录", Toast.LENGTH_SHORT).show();
                }

            }
        });
        bt2LogFour.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), LoginActivity.class));
            }
        });
    }

    @Override
    public void showToast(String msg) {

    }
}
